package pri.zey.custom.widget;/**
 * Created by Administrator on 2016/4/15 0015.
 */

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import pri.zey.custom.R;

/**
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>类描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>属性描述
 * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>方法描述
 */
public class EditTextErrot extends FrameLayout{

    private String ErrorText;
    private int ErrorIcon = android.R.drawable.ic_notification_overlay;
    private int ErrorBackground = android.R.color.background_light;
    private boolean ErrorVisibility = true;


    public EditTextErrot(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initAttr(context, attrs, defStyleAttr);
    }

    public EditTextErrot(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public EditTextErrot(Context context) {
        this(context, null, 0);
    }

    private void initAttr(Context context, AttributeSet attrs, int defStyleAttr){
        if (attrs == null){
            init(context);
            return;
        }
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.EditTextErrot);
        setErrorVisibility(ta.getBoolean(R.styleable.EditTextErrot_ErrorVisibility, ErrorVisibility));

        setErrorText(ta.getString(R.styleable.EditTextErrot_ErrorText));
        setErrorIcon(ta.getResourceId(R.styleable.EditTextErrot_ErrorIcon, ErrorIcon));
        setErrorBackground(ta.getColor(R.styleable.EditTextErrot_ErrorBackground, ErrorBackground));
        init(context);
    }

    private void init(Context context){
        LinearLayout mainlayout = new LinearLayout(context);

    }

    public String getErrorText() {
        return ErrorText;
    }

    public void setErrorText(String errorText) {
        ErrorText = errorText;
    }

    public int getErrorIcon() {
        return ErrorIcon;
    }

    public void setErrorIcon(int errorIcon) {
        ErrorIcon = errorIcon;
    }

    public int getErrorBackground() {
        return ErrorBackground;
    }

    public void setErrorBackground(int errorBackground) {
        ErrorBackground = errorBackground;
    }

    public boolean isErrorVisibility() {
        return ErrorVisibility;
    }

    public void setErrorVisibility(boolean errorVisibility) {
        ErrorVisibility = errorVisibility;
    }
}
